function BXDialogTree(){}BXDialogTree.prototype={Init:function(){this.arIconList={folder:"/bitrix/images/main/file_dialog/icons/folder.gif",folderopen:"/bitrix/images/main/file_dialog/icons/folderopen.gif",plus:"/bitrix/images/main/file_dialog/icons/plus.gif",minus:"/bitrix/images/main/file_dialog/icons/minus.gif",dot:"/bitrix/images/main/file_dialog/icons/dot.gif"};this.arDirConts={}},DisplayTree:function(){if(!this.oCont)this.oCont=BX("__bx_treeContainer");BXFDCleanNode(this.oCont);var e=arFDDirs["/"],t=jsUtils.CreateElement("TABLE",{className:"bxfd-tree-tbl"}),i=e.length,o;for(o=0;o<i;o++)this.DisplayElement(e[o],t.insertRow(-1).insertCell(-1));this.oCont.appendChild(t)},oPlusOnClick:function(e){this.OpenTreeSection(e.parentNode.parentNode.getAttribute("__bxpath"),"check")},oElementOnClick:function(e){oBXFileDialog.SetFocus("tree");this.SelectElement(e.parentNode.parentNode.getAttribute("__bxpath"))},SelectElement:function(e,t,i){if(this.curSelectedItem&&this.curSelectedItem.path==e)return true;var o=this.arDirConts[e];if(o&&o.firstChild){var n=o.firstChild.getElementsByTagName("SPAN"),l=n[0];if(this.curSelectedItem&&this.curSelectedItem.oTitle)this.UnHighlightElement(this.curSelectedItem.oTitle);this.HighlightElement(l);if(t!==false)this.OpenTreeSection(e,true);oBXDialogControls.dirPath.Set(e);if(i!==false)oBXDialogWindow.LoadFolderContent(e);this.curSelectedItem={path:e,oTitle:l}}},HighlightElement:function(e){e.id="__bx_SelectedTitle";e.className="bxfd-tree-item-sel"},UnHighlightElement:function(e){e.id="";e.className="bxfd-tree-item"},DisplayElement:function(e,t){this.arDirConts[e.path]=t;var i="<table>"+'<tr __bxpath="'+e.path+'" __bx_bOpen=0>'+'<td class="tree-node-folding" >';if(e.empty)i+='<img onclick="oBXDialogTree.oElementOnClick(this);" src="'+this.arIconList.dot+'" />';else i+='<img onclick="oBXDialogTree.oPlusOnClick(this);" src="'+this.arIconList.plus+'" />';i+='</td><td class="tree-node-icon" >'+'<img onclick="oBXDialogTree.oElementOnClick(this);" src="'+this.arIconList.folder+'" />'+'</td><td class="tree-node-name" >'+'<span onclick="oBXDialogTree.oElementOnClick(this);" class="bxfd-tree-item" unselectable="on">'+e.name+"</span>"+"</td></tr></table>";t.innerHTML=i},LoadTree:function(e,t,i){var o=new JCHttpRequest;o.Action=function(o){oWaitWindow.Hide();var n=oBXFileDialog.CheckReqLostSessid(o);if(n!==true){if(i)return alert("0"+FD_MESS.FD_SESS_EXPIRED);oBXFileDialog.sessid=n;return oBXDialogTree.LoadTree(e,t,true)}var l=0;var a=setInterval(function(){l++;if(window.action_warning!==false){clearInterval(a);if(!oBXDialogWindow.lastCorrectPath)oBXDialogWindow.lastCorrectPath="/";oBXDialogTree.SetPath(oBXDialogWindow.lastCorrectPath);return alert(window.action_warning)}else if(!window.load_items_correct){clearInterval(a);return alert(FD_MESS.FD_ERROR)}if(arFDDirs[e]||arFDFiles[e]||l>20){clearInterval(a);if(oBXDialogTree.bRedisplayTree)oBXDialogTree.DisplayTree();oBXDialogTree.bRedisplayTree=false;if(t===false)return oBXDialogTree.SetPath(e);if(t==="timeout")return oBXDialogTree.SetPath(e,false);if(typeof arFDDirs[e]=="object"&&arFDDirs[e].length>0)oBXDialogTree.DisplaySubTree(t,arFDDirs[e]);if(oBXDialogWindow.reloadWindowPath)oBXDialogWindow.LoadFolderContent(e);oBXDialogWindow.reloadWindowPath=true}},5)};oWaitWindow.Show();window.action_warning=false;window.load_items_correct=false;this.curLoadingPath=e;o.Send(oBXFileDialog.GetRequestUrl(getSite())+"&action=load&path="+jsUtils.urlencode(e)+"&add_to_menu="+(oBXFileDialog.oConfig.operation=="S"?"1":"")+"&rec="+(t===false?"2":"0"))},focusOnSelectedElment:function(){if(!this.curSelectedItem)return true;var e=this.curSelectedItem.oTitle,t=this.oCont.scrollTop;this.tmpFocusInp=jsUtils.CreateElement("INPUT",{size:1,id:"bx_fd_tmp_focus_inp"});e.parentNode.insertBefore(this.tmpFocusInp,e);setTimeout(function(){var e=oBXDialogTree.tmpFocusInp&&oBXDialogTree.tmpFocusInp.parentNode?oBXDialogTree.tmpFocusInp:BX("bx_fd_tmp_focus_inp");if(e){e.focus();var i=oBXDialogTree.oCont.scrollTop;if(t<i)oBXDialogTree.oCont.scrollTop+=120;e.parentNode.removeChild(e);e=null}},10)},OpenTreeSection:function(e,t){var i=this.arDirConts[e];if(!i)return;var o=i.getElementsByTagName("TABLE"),n=o[0].rows[0],l=n.getAttribute("__bx_bOpen"),a=o[0].getElementsByTagName("IMG"),r=a[0],s=a[1];if(r.src.indexOf("dot.gif")!=-1)return;if(t=="check")t=l!=1;if(t){n.setAttribute("__bx_bOpen",1);r.src=this.arIconList.minus;s.src=this.arIconList.folderopen;if(!window.arFDDirs[e])this.LoadTree(e,i);else this.DisplaySubTree(i,window.arFDDirs[e]);oBXDialogControls.dirPath.Set(e)}else{var d=o[1];if(!d)return;s.src=this.arIconList.folder;r.src=this.arIconList.plus;d.style.display="none";n.setAttribute("__bx_bOpen",0)}},HighlightPath:function(e){try{if(e==""||e=="/"){if(this.curSelectedItem&&this.curSelectedItem.oTitle)this.UnHighlightElement(this.curSelectedItem.oTitle);this.oCont.scrollTop=0;return}e=e.replace(/\\/gi,"/");var t=e.split("/"),i="",o,n,l=t.length;for(n=0;n<l;n++){o=t[n];if(o!=""){i+="/"+o;this.OpenTreeSection(i,true)}}var a=this.arDirConts[i],r=a.firstChild.getElementsByTagName("SPAN"),s=r[0];if(this.curSelectedItem&&this.curSelectedItem.oTitle)this.UnHighlightElement(this.curSelectedItem.oTitle);this.HighlightElement(s);this.curSelectedItem={path:i,oTitle:s}}catch(t){setTimeout(function(){oBXDialogTree.HighlightPath(e)},100)}oBXDialogTree.focusOnSelectedElment()},SetPath:function(e,t){e=e.replace(/\\/gi,"/");e=e.replace(/[\/]+$/g,"");e=BX.util.trim(e);if(e==""||e.indexOf("..")!=-1||e=="/"||e=="./"||e=="/."||e==".")e="/";if(!window.arFDDirs[e]&&!window.arFDFiles[e])return this.LoadTree(e,false);if(t!==false)oBXDialogTree.HighlightPath(e);oBXDialogControls.dirPath.Set(e);if(arFDDirs[e]&&arFDFiles[e])return oBXDialogWindow.DisplayFolderContent(e)},DisplaySubTree:function(e,t,i){if(!e||t===false)return;var o=e.getElementsByTagName("TABLE");if(i&&o[1])o[1].parentNode.removeChild(o[1]);if(o[1]&&!i){o[1].style.display="block"}else{var n=jsUtils.CreateElement("TABLE",{},{marginLeft:"15px"}),l=t.length,a,r;for(r=0;r<l;r++){a=n.insertRow(-1).insertCell(-1);this.DisplayElement(t[r],a)}e.appendChild(n)}},Append:function(){var e=oBXFileDialog.oConfig.path;if(e!="/"&&e.substr(e.length-1)=="/")e=e.substr(0,e.length-1);this.Init();this.DisplayTree();this.HighlightPath(e);var t=0,i=20;var o=setInterval(function(){t++;if(arFDDirs[e]||arFDFiles[e]||t>i){clearInterval(o);if(t<i+1)oBXDialogWindow.DisplayFolderContent(e)}},5);oBXDialogControls.dirPath.Set(e,false)},OnKeyDown:function(e){if(!this.curSelectedItem)return;var t=this.curSelectedItem.path,i=false,o,n,a,r,s;switch(e.keyCode){case 37:if(this.SectionIsOpened(t)){this.OpenTreeSection(t,false);break}o=t.lastIndexOf("/");n=o==0?"/":t.substr(0,o);a=arFDDirs[n];i=n=="/"?a[0].path:n;break;case 38:o=t.lastIndexOf("/");n=o==0?"/":t.substr(0,o);a=arFDDirs[n];l=a.length;if(l>0){for(r=0;r<l;r++){if(a[r].path==t){s=r;break}}}if(s==0&&n=="/")break;if(s==0){i=n;break}var d=a[s-1];if(this.SectionIsOpened(d.path)){var _=arFDDirs[d.path].length;if(_>0)i=arFDDirs[d.path][_-1].path}else{i=d.path}break;case 39:o=t.lastIndexOf("/");n=o==0?"/":t.substr(0,o);a=arFDDirs[n];l=a.length;if(l>0){for(r=0;r<l;r++){if(a[r].path==t){s=r;break}}}if(!a[s].empty){if(this.SectionIsOpened(t)&&arFDDirs[t]&&arFDDirs[t][0])i=arFDDirs[t][0].path;else this.OpenTreeSection(t,true)}break;case 40:o=t.lastIndexOf("/");n=o==0?"/":t.substr(0,o);a=arFDDirs[n];l=a.length;if(this.SectionIsOpened(t)&&arFDDirs[t]&&arFDDirs[t][0]){i=arFDDirs[t][0].path;break}if(l>0){for(r=0;r<l;r++){if(a[r].path==t){s=r;break}}}if(s+1<l){var f=a[s+1];i=f.path}else{if(n=="/")break;var c=n.lastIndexOf("/"),u=c==0?"/":n.substr(0,c),h=arFDDirs[u],g=h.length,D,p;if(g){for(D=0;D<g;D++){if(h[D].path==n){p=D;break}}if(p<g-1)i=h[p+1].path}}break;case 8:o=t.lastIndexOf("/");n=o==0?"/":t.substr(0,o);a=arFDDirs[n];i=n=="/"?a[0].path:n;break}if(i!==false){this.TimeoutSelectElement(i);return BX.PreventDefault(e)}},TimeoutSelectElement:function(e){if(this.selectTimeout)clearTimeout(this.selectTimeout);this.SelectElement(e,false,false);this.selectTimeout=setTimeout(function(){if(oBXDialogTree.curSelectedItem.path==e){oBXDialogWindow.LoadFolderContent(e,false,true);oBXDialogTree.focusOnSelectedElment()}},500)},SectionIsOpened:function(e){try{return this.arDirConts[e].firstChild.rows[0].getAttribute("__bx_bOpen")==1}catch(e){return false}}};function BXDialogWindow(){this.Init()}BXDialogWindow.prototype={Init:function(){this.pWnd=BX("__bx_windowContainer");this.view=oBXFileDialog.UserConfig.view;this.lastCorrectPath="";this.sort=oBXFileDialog.UserConfig.sort;this.sort_order=oBXFileDialog.UserConfig.sort_order;this.filter=oBXDialogControls.Filter.curentFilter;this.arFiles={};oBXDialogControls.ViewSelector.Set(this.view,false);oBXDialogControls.SortSelector.Set(this.sort,this.sort_order);var e=BX("BX_file_dialog_title");this.cancelRename_innerHTML="";if(oBXFileDialog.oConfig.operation=="S")e.innerHTML=FD_MESS.FD_SAVE_TAB_TITLE;else if(oBXFileDialog.oConfig.operation=="O"&&oBXFileDialog.oConfig.select=="D")e.innerHTML=FD_MESS.FD_OPEN_DIR;else e.innerHTML=FD_MESS.FD_OPEN_TAB_TITLE;BX("BX_file_dialog_close").title=FD_MESS.FD_CLOSE;this.iconsPath="/bitrix/images/main/file_dialog/icons/types/";this.arIcons={css:{small:"css.gif",big:"css_big.gif",type:"CSS "+FD_MESS.FD_FILE},csv:{small:"csv.gif",big:"csv_big.gif",type:"CSV "+FD_MESS.FD_FILE},file:{small:"file.gif",big:"file_big.gif",type:FD_MESS.FD_FILE},flash:{small:"flash.gif",big:"flash_big.gif",type:"Adobe Macromedia Flash "+FD_MESS.FD_FILE},folder:{small:"folder.gif",big:"folder_big.gif",type:FD_MESS.FD_FOLDER},gif:{small:"gif.gif",big:"gif_big.gif",type:FD_MESS.FD_IMAGE+" GIF"},htaccess:{small:"htaccess.gif",big:"htaccess_big.gif",type:"htaccess "+FD_MESS.FD_FILE},html:{small:"html.gif",big:"html_big.gif",type:"HTML "+FD_MESS.FD_FILE},jpg:{small:"jpeg.gif",big:"jpeg_big.gif",type:FD_MESS.FD_IMAGE+" JPG"},jpeg:{small:"jpeg.gif",big:"jpeg_big.gif",type:FD_MESS.FD_IMAGE+" JPEG"},js:{small:"js.gif",big:"js_big.gif",type:"Javascript "+FD_MESS.FD_FILE},php:{small:"php.gif",big:"php_big.gif",type:"PHP "+FD_MESS.FD_FILE},png:{small:"png.gif",big:"png_big.gif",type:FD_MESS.FD_IMAGE+" PNG"},txt:{small:"txt.gif",big:"txt_big.gif",type:"Text "+FD_MESS.FD_FILE},xml:{small:"xml.gif",big:"xml_big.gif",type:"XML "+FD_MESS.FD_FILE}};this.oCM=new BXFDContextMenu;this.oSorter=new BXFDSorter},LoadFolderContent:function(e,t,i){if(e.indexOf("..")!=-1)e="/";if(t===true){arFDDirs[e]=false;arFDFiles[e]=false}if(arFDDirs[e]&&arFDFiles[e]&&t!==true)return this.DisplayFolderContent(e);if(oBXDialogTree.curLoadingPath!=e)oBXDialogTree.LoadTree(e,i===true?"timeout":false)},DisplayFolderContent:function(e){if(e=="")e="/";var t=window.arFDPermission[e];if(oBXFileDialog.oConfig.operation=="O"&&oBXFileDialog.oConfig.showUploadTab&&t)oBXDialogTabs.DisableTab("tab2",!t.upload);if(arFDDirs[e]&&arFDFiles[e]){oBXDialogWindow.DisplayElementsList(arFDDirs[e],arFDFiles[e],oBXDialogWindow.view,oBXDialogWindow.filter,oBXDialogWindow.sort,oBXDialogWindow.sort_order)}this.reloadWindowPath=e;this.lastCorrectPath=e;oBXDialogControls.Preview.Clear();if(oBXFileDialog.oConfig.operation=="O")oBXDialogControls.filePath.Set("");if(oBXFileDialog.oConfig.operation=="S"&&oBXFileDialog.oConfig.showAddToMenuTab)oBXMenuHandling.ChangeMenuType()},DisplayElementsList:function(e,t,i,o,n,l){if(e===false&&t===false)return;if(typeof e!="object"||typeof t!="object")return;oBXDialogWindow.view=i;var a=this,r=e.length,s=t.length,d=[],_=o===""||o===false?"*":oBXDialogControls.Filter.arFilters[o],f,c,u,h,g,D,p,m,w;for(D=0;D<r;D++){f=e[D];d.push({name:f.name,icon:"folder",path:f.path,permission:f.permission,date:f.date,timestamp:f.timestamp,size:f.size})}if(oBXFileDialog.bSelectFiles){for(D=0;D<s;D++){w=false;c=t[D];h=c.name.substr(c.name.lastIndexOf(".")+1).toLowerCase();g=!this.arIcons[h]?"file":h;if(_!="*"){p=_.length;for(m=0;m<p;m++){if(h==_[m]){w=true;break}}}else w=true;if(w){d.push({name:c.name,icon:g,ext:h,path:c.path,permission:c.permission,date:c.date,timestamp:c.timestamp,size:c.size,tmb:c.tmb_src||""})}}}oWaitWindow.Show();setTimeout(function(){oBXDialogWindow.oNameInput=false;oBXDialogWindow.oSorter.Sort(d);a.arElIndex=[];a["DisplayElList_"+i](d);oBXDialogControls.NewDirButtonChange();oWaitWindow.Hide()},3)},DisplayElList_list:function(e){var t=function(e,t){var i=parseInt(e.style.width||e.offsetWidth);if(isNaN(i))i=0;var o=220;var n=t.insertCell(-1);e.style.width=i+o+"px";n.className="bx-valign-top";n.style.width=o+"px";return n};var i=BX("__bx_oSubContTable");if(i)i.parentNode.removeChild(i);i=this.pWnd.appendChild(jsUtils.CreateElement("TABLE",{id:"__bx_oSubContTable"},{height:"228px",width:"0px"}));var o=i.insertRow(-1);var n=e.length,l,a,r;if(n==0){r=t(i,o);a=r.appendChild(jsUtils.CreateElement("TABLE",{},{width:"100%"}))}else{for(l=0;l<n;l++){if(l%12==0){r=t(i,o);a=r.appendChild(jsUtils.CreateElement("TABLE",{},{width:"100%"}))}this.AddElementToList("list",a,e[l],l)}}this.Last_ElList_len=n},DisplayElList_detail:function(e){var t=BX("__bx_oSubContTable");if(t)t.parentNode.removeChild(t);t=document.createElement("TABLE");t.id="__bx_oSubContTable";this.pWnd.appendChild(t);t.style.height="0%";t.style.width="100%";var i=t.insertRow(-1);i.className="bxfd-det-view-head";var o=function(){l.innerHTML=FD_MESS.FD_SORT_NAME;a.innerHTML=FD_MESS.FD_SORT_SIZE;r.innerHTML=FD_MESS.FD_SORT_TYPE;s.innerHTML=FD_MESS.FD_SORT_DATE};var n=i.insertCell(-1),l=i.insertCell(-1),a=i.insertCell(-1),r=i.insertCell(-1),s=i.insertCell(-1);l.style.width="45%";n.style.width="15px";o();var d="<img src='/bitrix/images/main/file_dialog/arrow_"+(oBXDialogWindow.sort_order=="asc"?"up":"down")+".gif'>";switch(oBXDialogWindow.sort){case"name":l.innerHTML+="&nbsp;"+d;l.setAttribute("sort_order",oBXDialogWindow.sort_order);break;case"size":a.innerHTML+="&nbsp;"+d;a.setAttribute("sort_order",oBXDialogWindow.sort_order);break;case"type":r.innerHTML+="&nbsp;"+d;r.setAttribute("sort_order",oBXDialogWindow.sort_order);break;case"date":s.innerHTML+="&nbsp;"+d;s.setAttribute("sort_order",oBXDialogWindow.sort_order);break}var _=function(t,i){o();if(oBXDialogWindow.sort!=t){oBXDialogWindow.sort=t;var n="asc"}else n=i.getAttribute("sort_order")=="asc"?"des":"asc";i.setAttribute("sort_order",n);oBXDialogWindow.sort_order=n;var l="<img src='/bitrix/images/main/file_dialog/arrow_"+(oBXDialogWindow.sort_order=="asc"?"up":"down")+".gif'>";i.innerHTML+="&nbsp;"+l;oWaitWindow.Show();setTimeout(function(){oBXDialogControls.SortSelector.Set(t,n);oBXDialogWindow.oSorter.Sort(e);oBXDialogWindow.DisplayElList_detail(e);oWaitWindow.Hide()},5)};l.onclick=function(){_("name",l)};a.onclick=function(){_("size",a)};r.onclick=function(){_("type",r)};s.onclick=function(){_("date",s)};for(var f=0,c=e.length;f<c;f++)this.AddElementToList("detail",t,e[f],f)},DisplayElList_preview:function(e){var t=BX("__bx_oSubContTable");if(t)t.parentNode.removeChild(t);t=this.pWnd.appendChild(jsUtils.CreateElement("TABLE",{id:"__bx_oSubContTable"},{height:"0%",width:"100%"}));var i=t.insertRow(-1).insertCell(-1),o,n=e.length;for(o=0;o<n;o++)this.AddElementToList("preview",i,e[o],o)},AddElementToList:function(e,t,i,o){if(!i)return;this.arElIndex[o]=i;var n=i.icon!="folder"?getFileSize(i.size):"",l=jsUtils.IsIE()?i.name+(i.icon!="folder"?"\n"+FD_MESS.FD_SORT_SIZE+": "+n:"")+"\n"+FD_MESS.FD_SORT_DATE+": "+i.date:i.name,a,r;if(e=="list"){g=t.insertRow(-1);a=g.insertCell(-1);var s=g.insertCell(-1);r=oBXDialogWindow.iconsPath+oBXDialogWindow.arIcons[i.icon].small;a.innerHTML='<img src="'+r+'" title="'+l+'" />';a.style.width="0%";s.unselectable="on";s.title=l;s.className="bxfd-win-item";s.innerHTML="<span class='title'>"+oBXDialogWindow.checkNameLength(i.name,210)+"</span>"}else if(e=="detail"){g=t.insertRow(-1);g.className="bxfd-det-list-row";a=g.insertCell(-1);var d=g.insertCell(-1),_=g.insertCell(-1),f=g.insertCell(-1),c=g.insertCell(-1),u=oBXDialogWindow.arIcons[i.icon].type,h=i.date;r=oBXDialogWindow.iconsPath+oBXDialogWindow.arIcons[i.icon].small;a.innerHTML='<img src="'+r+'" title="'+l+'" />';a.style.width="10px";d.unselectable="on";d.style.cursor="default";d.style.textAlign="left";d.title=l;d.innerHTML="<span class='title'>"+oBXDialogWindow.checkNameLength(i.name,210)+"</span>";d.className="bxfd-win-item";_.style.textAlign="right";_.style.paddingRight="5px";_.innerHTML=n;f.innerHTML=u;c.innerHTML=h}else if(e=="preview"){var g=t.appendChild(jsUtils.CreateElement("DIV",{className:"bxfd-prev-cont",title:l})),D=g.appendChild(jsUtils.CreateElement("TABLE",{},{width:"100%",height:"100%"})),p=D.insertRow(-1).insertCell(-1),m=D.insertRow(-1).insertCell(-1);r=oBXFileDialog.oConfig.genThumb&&i.tmb?i.tmb:oBXDialogWindow.iconsPath+oBXDialogWindow.arIcons[i.icon].big;p.align="center";p.unselectable="on";p.valign="middle";p.style.height="110px";p.appendChild(jsUtils.CreateElement("IMG",{src:r}));m.align="center";m.unselectable="on";m.style.cursor="default";m.innerHTML=oBXDialogWindow.checkNameLength(i.name,170)+(n!=""?"<br />"+n:"")}oBXDialogWindow.AddElementsEventHandlers(g,i)},AddElementsEventHandlers:function(e,t){if(!t._winCont)t._winCont={};t._winCont[this.view]=e;this.arFiles[t.path]=t;e.setAttribute("__bxpath",t.path);if(t.icon=="folder"){e.onclick=function(e){oBXFileDialog.SetFocus("window");var t=this.getAttribute("__bxpath");var i=false;if(oBXFileDialog.bSelectDirs)i=getFileName(t);oBXDialogWindow.SelectElement(this,t,i)};e.ondblclick=function(e){oBXFileDialog.SetFocus("window");oBXDialogTree.SetPath(this.getAttribute("__bxpath"))}}else{e.onclick=function(e){if(!oBXFileDialog.bSelectFiles)return;oBXFileDialog.SetFocus("window");var t=this.getAttribute("__bxpath");oBXDialogWindow.SelectElement(this,t,getFileName(t))};e.ondblclick=function(e){var t=this.getAttribute("__bxpath");oBXDialogWindow.SelectElement(this,t,getFileName(t));oBXFileDialog.SubmitFileDialog()}}e.oncontextmenu=oBXDialogWindow.OnContextMenu},checkNameLength:function(e,t,i){if(e.length<=12)return e;if(!i)i=false;oDiv=document.createElement("DIV");oDiv.style.position="absolute";oDiv.innerHTML=e;document.body.appendChild(oDiv);w=oDiv.offsetWidth;document.body.removeChild(oDiv);if(w<t&&!i)return e;var o=e.length;name_base=e.substr(0,e.length-7);name_end=e.substr(e.length-7);if(w>=t)e=this.checkNameLength(name_base.substr(0,name_base.length-3)+name_end,t,true);else if(i)e=name_base+"..."+name_end;return e},SelectElement:function(e,t,i){this.curSelectedItem={cont:e,path:t};if(this.view=="preview"){var o=BX("bxfd_selected_element_preview");if(o)o.id="";if(e)e.id="bxfd_selected_element_preview"}else{var n=BX("bxfd_selected_element_icon"),l=BX("bxfd_selected_element_title");if(n)n.id="";if(l)l.id="";if(e)this.HighlightElement(e.cells[0],e.cells[1])}if(i){oBXDialogControls.filePath.Set(i);oBXDialogControls.Preview.Display(t)}},HighlightElement:function(e,t){if(e)e.id="bxfd_selected_element_icon";t.id="bxfd_selected_element_title"},AddNewElement:function(){oBXDialogWindow.oNameInput=false;switch(oBXDialogWindow.view){case"list":this.AddNewElement_list();break;case"detail":this.AddNewElement_detail();break;case"preview":this.AddNewElement_preview();break}},AddNewElement_list:function(){var e=function(e,t){var i=220;e.style.width=parseInt(e.style.width)+i+"px";var o=t.insertCell(-1);o.className="bx-valign-top";o.style.width=i+"px";return o};var t=function(e,t){oR=e.insertRow(-1);var i=oR.insertCell(-1);var o=oBXDialogWindow.iconsPath+oBXDialogWindow.arIcons["folder"].small;i.innerHTML='<img src="'+o+'"/>';i.style.width="0%";oTitleCell=oR.insertCell(-1);oTitleCell.unselectable="on";oTitleCell.style.cursor="default";oTitleCell.style.width="100%";oTitleCell.style.textAlign="left";var n=oTitleCell.appendChild(jsUtils.CreateElement("INPUT",{type:"text",value:oBXDialogControls.DefaultDirName,id:"__edited_element",__bx_mode:"new"},{width:"100%"}));oBXDialogWindow.oNameInput=n;oBXDialogWindow.SelectInput(n);jsUtils.addEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress);jsUtils.addEvent(n,"blur",oBXDialogWindow.OnElementBlur)};var i=BX("__bx_oSubContTable"),o=i.rows[0],n=o.cells[o.cells.length-1].childNodes[0];if(this.Last_ElList_len%12==0&&this.Last_ElList_len>0){oSubCont=e(i,o);n=oSubCont.appendChild(document.createElement("TABLE"));n.style.width="100%"}t(n)},AddNewElement_detail:function(){var e=function(e){var t=e.insertRow(-1);var i=t.insertCell(-1);var o=oBXDialogWindow.iconsPath+oBXDialogWindow.arIcons["folder"].small;i.innerHTML='<img src="'+o+'" />';i.style.width="10px";var n=t.insertCell(-1);n.className="bxfd-win-item";var l=t.insertCell(-1);var a=t.insertCell(-1);var r=t.insertCell(-1);var s=n.appendChild(jsUtils.CreateElement("INPUT",{type:"text",value:oBXDialogControls.DefaultDirName,id:"__edited_element",__bx_mode:"new"},{width:"100%"}));oBXDialogWindow.oNameInput=s;oBXDialogWindow.SelectInput(s);jsUtils.addEvent(document,"keydown",oBXDialogWindow.OnElementKeyPress);jsUtils.addEvent(s,"blur",oBXDialogWindow.OnElementBlur)};var t=BX("__bx_oSubContTable");e(t)},AddNewElement_preview:function(){var e=function(e){var t=e.appendChild(jsUtils.CreateElement("DIV",{className:"bxfd-prev-cont"}));var i=t.appendChild(jsUtils.CreateElement("TABLE",{},{width:"100%",height:"100%"}));var o=i.insertRow(-1).insertCell(-1);o.align="center";o.unselectable="on";o.valign="middle";o.style.height="110px";var n=i.insertRow(-1).insertCell(-1);o.appendChild(jsUtils.CreateElement("IMG",{src:oBXDialogWindow.iconsPath+oBXDialogWindow.arIcons["folder"].big}));var l=n.appendChild(jsUtils.CreateElement("INPUT",{type:"text",value:oBXDialogControls.DefaultDirName,id:"__edited_element",__bx_mode:"new"},{width:"100%"}));oBXDialogWindow.oNameInput=l;oBXDialogWindow.oNameInput=l;oBXDialogWindow.SelectInput(l);jsUtils.addEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress);jsUtils.addEvent(l,"blur",oBXDialogWindow.OnElementBlur)};var t=BX("__bx_oSubContTable");var i=t.rows[0].cells[0];e(i)},RenameElement:function(e){var t=e.getAttribute("__bxpath"),i=oBXDialogWindow.arFiles[t],o;oBXFileDialog.SetFocus("");oBXDialogWindow.oNameInput=false;if(e.nodeName.toUpperCase()=="TABLE")o=e.cells[1];else o=e.getElementsByTagName("TD")[1];oBXDialogWindow.cancelRename_innerHTML=o.innerHTML;o.innerHTML="";var n=o.appendChild(jsUtils.CreateElement("INPUT",{type:"text",value:i.name,id:"__edited_element",__bx_mode:"rename",__bx_old_name:i.name},{width:"100%"}));oBXDialogWindow.oNameInput=n;oBXDialogWindow.SelectInput(n);jsUtils.addEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress);jsUtils.addEvent(n,"blur",oBXDialogWindow.OnElementBlur)},OnElementKeyPress:function(e){try{if(!e)e=window.event;if(!e)return;var t=e.keyCode==27;var i=e.keyCode==13;if(t||i){var o=BX("__edited_element");jsUtils.removeEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress);jsUtils.removeEvent(o,"blur",oBXDialogWindow.OnElementBlur);var n=o.getAttribute("__bx_mode");if(n=="new")oBXDialogWindow.NewDir(t?oBXDialogControls.DefaultDirName:o.value);else if(n=="rename"){var l=o.getAttribute("__bx_old_name");if(t)oBXDialogWindow.CancelRename();else oBXDialogWindow.Rename(l,o.value)}}}catch(e){}},OnElementBlur:function(e){var t=BX("__edited_element");if(!t)return;jsUtils.removeEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress);jsUtils.removeEvent(t,"blur",oBXDialogWindow.OnElementBlur);var i=t.getAttribute("__bx_mode");if(i=="new")oBXDialogWindow.NewDir(t.value);else if(i=="rename"){var o=t.getAttribute("__bx_old_name");oBXDialogWindow.Rename(o,t.value)}},NewDir:function(e,t){var i=oBXDialogControls.dirPath.Get();setTimeout(function(){var o=new JCHttpRequest;window.action_warning="";o.Action=function(o){setTimeout(function(){oWaitWindow.Hide();var n=oBXFileDialog.CheckReqLostSessid(o);if(n!==true){if(t)return alert(FD_MESS.FD_SESS_EXPIRED);oBXFileDialog.sessid=n;return oBXDialogWindow.NewDir(e,true)}if(!window.action_status){if(window.action_warning.length>0)alert(window.action_warning);var l=BX("__edited_element");if(l){oBXDialogWindow.SelectInput(l);jsUtils.addEvent(l,"blur",oBXDialogWindow.OnElementBlur);jsUtils.addEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress)}}else if(window.action_status===true){arFDDirs[i+"/"+e]=[];arFDFiles[i+"/"+e]=[];oBXDialogWindow.DisplayFolderContent(i);var a=i.lastIndexOf("/"),r=a==0?"/":i.substr(0,a),s=arFDDirs[r],d=s.length,_;for(_=0;_<d;_++){if(s[_].path==i){s[_].empty=false;break}}oBXDialogTree.DisplaySubTree(oBXDialogTree.arDirConts[r],window.arFDDirs[r],true);oBXDialogTree.HighlightPath(i);setTimeout(function(){var t;if(i=="/")t="/"+e;else t=i+"/"+e;var o=oBXDialogWindow.arFiles[t];if(o&&o._winCont&&o._winCont[oBXDialogWindow.view])oBXDialogWindow.SelectElement(o._winCont[oBXDialogWindow.view],e);if(i=="/")oBXDialogTree.DisplayTree();else oBXDialogTree.DisplaySubTree(oBXDialogTree.arDirConts[i],window.arFDDirs[i],true)},50)}},5)};var n=oBXDialogWindow.ClientSideCheck(i,e,false,true);if(n!==true){setTimeout(function(){if(!window.oBXFileDialog)return;alert(n);var e=BX("__edited_element");if(e){oBXDialogWindow.SelectInput(e);jsUtils.addEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress);jsUtils.addEvent(e,"blur",oBXDialogWindow.OnElementBlur)}},250)}else{oWaitWindow.Show();oBXFileDialog.RequestUrl=oBXFileDialog.GetRequestUrl(getSite());o.Send(oBXFileDialog.RequestUrl+"&action=new_dir&path="+jsUtils.urlencode(i)+"&name="+jsUtils.urlencode(e)+"&add_to_menu="+(oBXFileDialog.oConfig.operation=="S"?"1":""))}},5)},Remove:function(e,t,i){var o=new JCHttpRequest;window.action_warning="";o.Action=function(o){setTimeout(function(){oWaitWindow.Hide();var n=oBXFileDialog.CheckReqLostSessid(o);if(n!==true){if(i)return alert(FD_MESS.FD_SESS_EXPIRED);oBXFileDialog.sessid=n;return oBXDialogWindow.Remove(e,t,true)}if(!window.action_status){if(window.action_warning.length>0)return alert(window.action_warning)}else if(window.action_status===true){var l=e.lastIndexOf("/");if(l!=-1){var a,r=e.length;for(a in window.arFDDirs){if(a.substr(0,r)==e){window.arFDDirs[a]=false}}for(a in window.arFDFiles){if(a.substr(0,r)==e)window.arFDFiles[a]=false}var s=l==0?"/":e.substr(0,l);oBXDialogWindow.DisplayFolderContent(s);if(t){var d=s,_=arFDDirs[s];if(_.length==0){var f=s.lastIndexOf("/"),c=s.substr(0,f),u;if(arFDDirs[c]&&arFDDirs[c].length){for(u=0;u<arFDDirs[c].length;u++){if(arFDDirs[c][u]&&arFDDirs[c][u].path==s){arFDDirs[c][u].empty=true;break}}}d=c}oBXDialogTree.DisplaySubTree(oBXDialogTree.arDirConts[d],window.arFDDirs[d],true);oBXDialogTree.HighlightPath(s)}}}},5)};oWaitWindow.Show();oBXFileDialog.RequestUrl=oBXFileDialog.GetRequestUrl(getSite());o.Send(oBXFileDialog.RequestUrl+"&action=remove&path="+jsUtils.urlencode(e)+"&add_to_menu="+(oBXFileDialog.oConfig.operation=="S"?"1":""))},Rename:function(e,t,i){if(e==t)return oBXDialogWindow.CancelRename();var o=oBXDialogControls.dirPath.Get(),n=oBXDialogWindow.arFiles[(o=="/"?"":o)+"/"+e],l=n.icon=="folder",a=oBXDialogWindow.ClientSideCheck(o,t,!l,l);if(a!==true){setTimeout(function(){if(!window.oBXFileDialog)return;alert(a);var t=BX("__edited_element");if(t){t.value=e;oBXDialogWindow.SelectInput(t);jsUtils.addEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress);jsUtils.addEvent(t,"blur",oBXDialogWindow.OnElementBlur)}},100)}else{var r=new JCHttpRequest;window.action_warning="";r.Action=function(n){if(!window.oBXFileDialog)return;setTimeout(function(){oWaitWindow.Hide();var l=oBXFileDialog.CheckReqLostSessid(n);if(l!==true){if(i)return alert(FD_MESS.FD_SESS_EXPIRED);oBXFileDialog.sessid=l;return oBXDialogWindow.Rename(e,t,true)}if(!window.action_status){if(window.action_warning.length>0)alert(window.action_warning);var a=BX("__edited_element");if(a){oBXDialogWindow.SelectInput(a);jsUtils.addEvent(a,"blur",oBXDialogWindow.OnElementBlur);jsUtils.addEvent(document,"keypress",oBXDialogWindow.OnElementKeyPress)}}else if(window.action_status===true){oBXDialogWindow.DisplayFolderContent(o);var r=oBXDialogTree.arDirConts[o];if(r)oBXDialogTree.DisplaySubTree(r,window.arFDDirs[o],true)}},5)};oWaitWindow.Show();oBXFileDialog.RequestUrl=oBXFileDialog.GetRequestUrl(getSite());r.Send(oBXFileDialog.RequestUrl+"&action=rename&path="+jsUtils.urlencode(o)+"&add_to_menu="+(oBXFileDialog.oConfig.operation=="S"?"1":"")+"&name="+jsUtils.urlencode(t)+"&old_name="+jsUtils.urlencode(e))}},CancelRename:function(){var e=BX("__edited_element");if(e)e.parentNode.innerHTML=oBXDialogWindow.cancelRename_innerHTML;oBXDialogWindow.oNameInput=false},ClientSideCheck:function(e,t,i,o){if(t.length<=0)return FD_MESS.FD_EMPTY_NAME;var n,l=t.replace(/[\\\/:*?\"\'<>|]/i,"");if(t!==l)return FD_MESS.FD_INCORRECT_NAME;if(i&&oBXFileDialog.bSelectFiles)for(n in arFDFiles[e])if(arFDFiles[e][n].name==t)return FD_MESS.FD_NEWFILE_EXISTS;if(o)for(n in arFDDirs[e])if(arFDDirs[e][n].name==t)return FD_MESS.FD_NEWFOLDER_EXISTS;return true},SelectInput:function(e,t){if(!t)t=oBXDialogControls.DefaultDirName;if(!e)e=BX("__edited_element");if(!e)return;e.select();e.focus()},OnContextMenu:function(e){var t=this,i=t.getAttribute("__bxpath"),o=oBXDialogWindow.arFiles[i];if(!e)e=window.event;if(!e||!o)return;oBXFileDialog.SetFocus("window");oBXDialogWindow.SelectElement(t,i);if(o.permission.del||o.permission.ren){if(e.pageX||e.pageY){e.realX=e.pageX;e.realY=e.pageY}else if(e.clientX||e.clientY){e.realX=e.clientX+document.body.scrollLeft;e.realY=e.clientY+document.body.scrollTop}var n=[];if(o.permission.ren){n.push({id:"rename",src:"/bitrix/images/main/file_dialog/rename.gif",name:FD_MESS.FD_RENAME,title:FD_MESS.FD_RENAME_TITLE,handler:function(){oBXDialogWindow.RenameElement(t)}})}if(o.permission.del){if(n.length>0)n.push("separator");n.push({id:"delete",src:"/bitrix/images/main/file_dialog/delete.gif",name:FD_MESS.FD_DELETE,title:FD_MESS.FD_DELETE_TITLE,handler:function(){if(confirm(o.icon=="folder"?FD_MESS.FD_CONFIRM_DEL_DIR:FD_MESS.FD_CONFIRM_DEL_FILE))oBXDialogWindow.Remove(i,o.icon=="folder")}})}oBXDialogWindow.oCM.Show(3500,0,{left:e.realX,top:e.realY},n)}else if(oBXDialogWindow.oCM)oBXDialogWindow.oCM.menu.PopupHide();return BX.PreventDefault(e)},OnKeyDown:function(e){if(oBXDialogWindow.oNameInput!==false)return true;var t=false,i,o,n;switch(e.keyCode){case 37:if(this.view!="detail"){i=this.GetCurIndex(this.curSelectedItem.path);if(this.view=="list")t=i-12;else t=i-1;if(t<0)t=0;break}case 38:i=this.GetCurIndex(this.curSelectedItem.path);if(i===false||i<=0)return;if(this.view=="preview")t=i>2?i-3:0;else t=i-1;break;case 39:if(this.view!="detail"){i=this.GetCurIndex(this.curSelectedItem.path);o=this.arElIndex.length;if(i===false||i==o-1)return;if(this.view=="list")t=i+12;else t=i+1;if(t>o-1)t=o-1;break}case 40:i=this.GetCurIndex(this.curSelectedItem.path);o=this.arElIndex.length;if(i===false||i>=o-1)return;if(this.view=="preview")t=i<o-4?i+3:o-1;else t=i+1;break;case 46:n=this.arElIndex[this.GetCurIndex(this.curSelectedItem.path)];if(n){if(n.permission.del&&confirm(n.icon=="folder"?FD_MESS.FD_CONFIRM_DEL_DIR:FD_MESS.FD_CONFIRM_DEL_FILE))oBXDialogWindow.Remove(this.curSelectedItem.path,n.icon=="folder");return BX.PreventDefault(e)}break;case 113:n=this.arElIndex[this.GetCurIndex(this.curSelectedItem.path)];if(n){if(n.permission.ren)oBXDialogWindow.RenameElement(this.curSelectedItem.cont);return BX.PreventDefault(e)}break;case 13:n=this.arElIndex[this.GetCurIndex(this.curSelectedItem.path)];if(n){n=this.arElIndex[this.GetCurIndex(this.curSelectedItem.path)];if(n.icon=="folder")oBXDialogTree.SetPath(this.curSelectedItem.path);else oBXFileDialog.SubmitFileDialog();return BX.PreventDefault(e)}}if(t!==false){var l=this.arElIndex[t];var a=false;if(l.icon=="folder"&&oBXFileDialog.bSelectDirs||l.icon!="folder"&&oBXFileDialog.bSelectFiles)a=l.name;this.SelectElement(l._winCont[this.view],l.path,a);return BX.PreventDefault(e)}},GetCurIndex:function(e){for(var t=0,i=this.arElIndex.length;t<i;t++){if(this.arElIndex[t].path==e)return t}return false}};function BXDialogTabs(){this.Init()}BXDialogTabs.prototype={Init:function(){this.contTable=BX("__bx_tab_cont");this.arTabs={};this.tabsCount=0;this.activeTabName=""},AddTab:function(e,t,i,o){this.arTabs[e]={name:e,title:t,func:i,active:o,disable:false};if(o){if(this.activeTabName!=""&&this.activeTabName!=e)this.arTabs[this.activeTabName].active=false;this.activeTabName=e}this.tabsCount++},DisplayTabs:function(){this.contTable.innerHTML="";if(this.tabsCount<2)return;var e=this;var t=function(e,t,i){var o="background-image: url(/bitrix/images/main/file_dialog/tabs/tab_icons.gif);";e.innerHTML='<img class=" '+i+'" src="/bitrix/images/1.gif" height="27px" width="'+t+'px" style="'+o+'"/>'};var i=function(t,i,o,n,l,a){t.innerHTML="<span style='white-space: nowrap !important; margin: 0 5px;'>"+o+"</span>";t.style.cursor="default";if(l)t.className="fd_tabs_a";else if(a)t.className="fd_tabs_pd";else t.className="fd_tabs_p";if(!a)t.onclick=function(t){e.SetActive(i,!l)};t.title=n};var o=0,n,l,a,r,s,d=this.contTable.appendChild(document.createElement("TABLE"));d.className="tab-content-table";var _=d.insertRow(-1);for(s in this.arTabs){o++;n=this.arTabs[s];oCell_1=_.insertCell(-1);oCell_1.style.width="0%";oCell_2=_.insertCell(-1);oCell_2.style.width="0%";if(o==1){if(n.active)t(oCell_1,6,"fd_tabs_0a");else t(oCell_1,6,"fd_tabs_0p");i(oCell_2,n.name,n.title,_ReplaceNbspBySpace(n.title),n.active,n.disable)}else if(this.tabsCount==o){oCell_3=_.insertCell(-1);if(n.active){t(oCell_1,11,"fd_tabs_pa");i(oCell_2,n.name,n.title,_ReplaceNbspBySpace(n.title),n.active,n.disable);t(oCell_3,9,"fd_tabs_a0")}else{t(oCell_1,11,"fd_tabs_ap");i(oCell_2,n.name,n.title,_ReplaceNbspBySpace(n.title),n.active,n.disable);t(oCell_3,9,"fd_tabs_p0")}}}lastCell=_.insertCell(-1);lastCell.style.width="100%";lastCell.className="fd_tabs_0"},SetActive:function(e,t){var i=this.arTabs[e];if(i.active)return;for(var o in this.arTabs)this.arTabs[o].active=false;i.active=true;if(i.func)i.func();this.DisplayTabs()},DisableTab:function(e,t){if(!this.arTabs[e]||this.arTabs[e].disable==t)return;var i=false;for(var o in this.arTabs){this.arTabs[o].active=false;if(o==e||i)continue;this.arTabs[o].active=true;this.arTabs[o].func();i=true}this.arTabs[e].disable=t;this.DisplayTabs()}};function BXDialogControls(){var e=this;this.DefaultDirName="New Folder";this.dirPath=new __DirPathBar;this.filePath=new __FilePathBar;this.Preview=new __Preview;this.ViewSelector=new __ViewSelector;this.SortSelector=new __SortSelector;this.Uploader=new __Uploader;this.Filter=new __FileFilter;this.History=new __History;this.currentSite=BXSite;window.fd_view_list.BuildItems();this.fd_view_list_frame=document.body.appendChild(jsUtils.CreateElement("IFRAME",{id:"fd_view_list_frame",src:"javascript:''",className:"bxfd-sys-frame"}));if(window.fd_site_list){window.fd_site_list.BuildItems();this.fd_site_list_frame=document.body.appendChild(jsUtils.CreateElement("IFRAME",{id:"fd_site_list_frame",src:"javascript:''",className:"bxfd-sys-frame"}))}var t=BX("__bx_fd_submit_but");if(oBXFileDialog.oConfig.operation=="O"){t.value=FD_MESS.FD_BUT_OPEN;t.onclick=SubmitFileDialog}else if(oBXFileDialog.oConfig.operation=="S"){t.value=FD_MESS.FD_BUT_SAVE;t.onclick=SubmitFileDialog;if(oBXFileDialog.oConfig.showAddToMenuTab){var i=BX("__bx_fd_submit_but2");i.value=FD_MESS.FD_BUT_SAVE;i.onclick=SubmitFileDialog}}if(oBXFileDialog.oConfig.operation=="S"&&oBXFileDialog.oConfig.showAddToMenuTab){BX("__bx_page_title_cont").style.display="block";this.PageTitle1=BX("__bx_page_title1");this.PageTitle2=BX("__bx_page_title2");this.PageTitle1.onchange=function(t){e.PageTitle2.value=this.value};this.PageTitle2.onchange=function(t){e.PageTitle1.value=this.value};this.PageTitle={};this.PageTitle.Get=function(){return e.PageTitle1.value};this.PageTitle.Set=function(t){e.PageTitle1.value=e.PageTitle2.value=t};var o=BX("title");if(o)this.PageTitle.Set(o.value);else this.PageTitle.Set("Title")}this.GoButton=BX("__bx_dir_path_go");this.GoButton.onclick=function(e){oBXDialogTree.SetPath(oBXDialogControls.dirPath.Get(true))};this.UpButton=BX("__bx_dir_path_up");this.UpButton.onclick=function(e){var t=oBXDialogControls.dirPath.Get(true);if(t!="/")oBXDialogTree.SetPath(t.substr(0,t.lastIndexOf("/")))};this.RootButton=BX("__bx_dir_path_root");this.RootButton.onclick=function(e){if(oBXDialogControls.dirPath.Get(true)!="/")oBXDialogTree.SetPath("/")};this.NewDirButton=BX("__bx_new_dir");this.NewDirButton.onclick=function(e){oBXDialogWindow.AddNewElement()};this.NewDirButtonActive=true;this.NewDirButtonChange=function(){var e=oBXDialogControls.dirPath.Get();if(e=="")e="/";var t=window.arFDPermission[e];if(t){if(t.new_folder&&!this.NewDirButtonActive){this.NewDirButton.className="fd_iconkit new_dir";this.NewDirButtonActive=true}else if(!t.new_folder&&this.NewDirButtonActive){this.NewDirButton.className="fd_iconkit new_dir_dis";this.NewDirButtonActive=false}}}}BXDialogControls.prototype.RefreshOnclick=function(){arFDDirs={};arFDFiles={};arFDPermission={};BXDialogWindow.arFiles={};oBXDialogTree.bRedisplayTree=true;if(oBXDialogTree.curSelectedItem&&oBXDialogTree.curSelectedItem.oTitle){oBXDialogTree.UnHighlightElement(oBXDialogTree.curSelectedItem.oTitle)}oBXDialogTree.curSelectedItem=null;var e=oBXDialogControls.dirPath.Get()||"/";oBXDialogTree.SetPath(e)};BXDialogControls.prototype.SiteSelectorOnChange=function(e){if(this.currentSite!=e){if(!window.bx_fd_site_selector)window.bx_fd_site_selector=BX("__bx_site_selector");window.bx_fd_site_selector.innerHTML="<span>"+e+'</span><span class="fd_iconkit site_selector_div_arrow">&nbsp;&nbsp;</span>';this.currentSite=e;oBXDialogControls.dirPath.Set("/");this.RefreshOnclick();fd_site_list.SetItemIcon(window.bx_fd_site_selector.getAttribute("bxvalue"),"");fd_site_list.SetItemIcon(e,"checked");window.bx_fd_site_selector.setAttribute("bxvalue",e)}window.fd_site_list.PopupHide()};BXDialogControls.prototype.SiteSelectorOnClick=function(e){var t=jsUtils.GetRealPos(e);t.left+=2;setTimeout(function(){window.fd_site_list.PopupShow(t)},5)};function BXFDSorter(){}BXFDSorter.prototype={name:function(e,t){var i=oBXDialogWindow.oSorter;if(e.icon=="folder"&&t.icon=="folder"||e.icon!="folder"&&t.icon!="folder")return i.common_sort(e.name,t.name);else if(e.icon=="folder"&&t.icon!="folder")return i.order=="des"?1:-1;else return i.order=="des"?-1:1},size:function(e,t){return oBXDialogWindow.oSorter.common_sort(parseInt(e.size),parseInt(t.size))},type:function(e,t){var i=oBXDialogWindow.oSorter;if(e.icon=="folder"&&t.icon=="folder"||e.ext==t.ext)return i.common_sort(e.name,t.name);else if(e.icon!="folder"&&t.icon!="folder")return i.common_sort(e.ext,t.ext);else if(e.icon=="folder"&&t.icon!="folder")return i.order=="des"?1:-1;else return i.order=="des"?-1:1},date:function(e,t){var i=oBXDialogWindow.oSorter,o=parseInt(e.timestamp),n=parseInt(t.timestamp);if(e.icon=="folder"&&t.icon=="folder"||e.icon!="folder"&&t.icon!="folder")return i.common_sort(o,n);else if(e.icon=="folder"&&t.icon!="folder")return i.order=="des"?1:-1;else return i.order=="des"?-1:1},common_sort:function(e,t){var i=oBXDialogWindow.oSorter,o=1;if(e<t)o=-1;else if(e==t)o=0;if(i.order=="des")o=-o;return o},Sort:function(e){this.order=oBXDialogWindow.sort_order;e.sort(this[oBXDialogWindow.sort||"name"]);return e}};function __DirPathBar(){this.oInput=BX("__bx_dir_path_bar");this.oInput.onclick=function(e){oBXFileDialog.SetFocus("name")};this.value=this.oInput.value;this.butBack=BX("__bx_dir_path_back");this.butForward=BX("__bx_dir_path_forward");this.butBack.onclick=function(e){var t=oBXDialogControls.History.Back();if(t!==false)oBXDialogTree.SetPath(t)};this.butForward.onclick=function(e){var t=oBXDialogControls.History.Forward();if(t!==false)oBXDialogTree.SetPath(t)};__DirPathBar.prototype.Set=function(e,t){if(!e||e=="")e="/";e=e.replace(/\/\//gi,"/");if(this.value!=e){this.oInput.value=this.value=e;this.OnChange(t)}else this.oInput.value=this.value=e};__DirPathBar.prototype.Get=function(e){var t=this.oInput.value;t=t.replace(/\\/gi,"/");t=t.replace(/\/\//gi,"/");if(t.substr(t.length-1)=="/")t=t.substr(0,t.length-1);if(t=="")t="/";return t};__DirPathBar.prototype.OnChange=function(e){var t=this.Get();oBXDialogControls.UpButton.className="fd_iconkit "+(t==""?"dir_path_up_dis":"dir_path_up");oBXFileDialog.UserConfig.path=t;oBXDialogControls.History.Push(t)}}function __FilePathBar(){__FilePathBar.prototype.Init=function(){this.oInput=BX("__bx_file_path_bar");if(oBXFileDialog.oConfig.operation=="S"){var e=BX("filename");if(e&&e.value.length>0)this.defaultName=e.value;else{var t=oBXFileDialog.oConfig.fileFilter,i;if(t.length>0){var o=t.indexOf(",");i=o>0?t.substr(0,o):t}else i="php";this.defaultName="untitled."+i}}this.oInput.onclick=function(){this.focus();oBXFileDialog.SetFocus("name")}};__FilePathBar.prototype.Set=function(e){this.oInput.value=e};__FilePathBar.prototype.Get=function(){return this.oInput.value};this.Init()}function __Preview(){this.Init()}__Preview.prototype={Init:function(){this.oDiv=BX("bxfd_previewContainer");this.addInfoCont=BX("bxfd_addInfoContainer");if(oBXFileDialog.oConfig.select=="D")this.oDiv.parentNode.style.visibility="hidden"},Display:function(e){this.Clear();if(!oBXDialogWindow.arFiles[e])return;if(BXFDIsImage(e))this.DisplayImage(e);else if(getExtension(e)=="swf")this.DisplayFlash(e);else this.DisplayBigIcon(e)},DisplayImage:function(e){var t=oBXDialogWindow.arFiles[e],i=this,o;if(oBXFileDialog.oConfig.genThumb&&t.tmb)return i._DisplayImage(t);var n=BX("__bx_get_real_size_cont");BXFDCleanNode(n);var l=n.appendChild(jsUtils.CreateElement("IMG",{src:e}));l.onload=function(){i._DisplayImage(t,this.offsetWidth||100,this.offsetHeight||100)}},_DisplayImage:function(e,t,i){var o,n,l=e.date.substr(0,e.date.lastIndexOf(":")),a=e.tmb||e.path;this.addInfoCont.innerHTML=getFileSize(e.size)+"  "+l;if(t&&i){var r=100,s=130;o=t+"px";n=i+"px";if(r/s>i/t){if(t>s){o=s+"px";n=Math.round(i*s/t)+"px"}}else{if(i>r){n=r+"px";o=Math.round(t*r/i)+"px"}}a=e.path}var d=this.oDiv.appendChild(jsUtils.CreateElement("IMG",{src:a,align:"middle"}));if(o&&n){d.style.width=o;d.style.height=n}this.oDiv.className=""},DisplayFlash:function(e){var t=oBXDialogWindow.arFiles[e],i=t.date.substr(0,t.date.lastIndexOf(":")),o=this.oDiv.appendChild(jsUtils.CreateElement("IFRAME",{id:"bxfd_ifrm_flash",frameborder:"0"}));this.addInfoCont.innerHTML=getFileSize(t.size)+" "+i;o.setAttribute("src",oBXFileDialog.GetRequestUrl(getSite())+"&action=flash&path="+jsUtils.urlencode(e));this.oDiv.className=""},DisplayBigIcon:function(e){var t=oBXDialogWindow.arFiles[e];if(t.icon=="folder")return;var i=t.date.substr(0,t.date.lastIndexOf(":")),o=oBXDialogWindow.iconsPath+oBXDialogWindow.arIcons[t.icon].big;this.addInfoCont.innerHTML=getFileSize(t.size)+" "+i;this.oDiv.appendChild(jsUtils.CreateElement("IMG",{src:o},{width:"25px",height:"25px"}));this.oDiv.className="bxfd-prev-big-icon"},Clear:function(){this.oDiv.innerHTML="";this.oDiv.className="";this.addInfoCont.innerHTML=""}};function __ViewSelector(){this.oSel=BX("__bx_view_selector");this.value="";__ViewSelector.prototype.OnClick=function(){var e=jsUtils.GetRealPos(this.oSel);e.left+=7;e.top+=6;setTimeout(function(){window.fd_view_list.PopupShow(e);if(BX("fd_view_list"))BX("fd_view_list").style.zIndex=3510},5)};__ViewSelector.prototype.OnChange=function(e){oWaitWindow.Show();setTimeout(function(){var t=oBXDialogControls.dirPath.Get(true);oBXDialogWindow.DisplayElementsList(arFDDirs[t],arFDFiles[t],e,oBXDialogWindow.filter,oBXDialogWindow.sort,oBXDialogWindow.sort_order);oWaitWindow.Hide();oBXDialogControls.ViewSelector.Set(e,true)},3)};__ViewSelector.prototype.Set=function(e,t){var i=this.oSel.getAttribute("bxvalue")||"";fd_view_list.SetItemIcon(i,"");fd_view_list.SetItemIcon(e,"checked");this.oSel.setAttribute("bxvalue",e);this.value=e;window.fd_view_list.PopupHide();oBXFileDialog.UserConfig.view=e};__ViewSelector.prototype.Get=function(){return this.value}}function __SortSelector(){var e=this;this.oSel=BX("__bx_sort_selector");this.oCheck=BX("__bx_sort_order");this.oSel.onchange=function(){if(oBXDialogWindow.sort==this.value)return;oWaitWindow.Show();oBXDialogControls.SortSelector.OnChange();oBXDialogWindow.sort=this.value;setTimeout(function(){var e=oBXDialogControls.dirPath.Get(true);oBXDialogWindow.DisplayElementsList(arFDDirs[e],arFDFiles[e],oBXDialogWindow.view,oBXDialogWindow.filter,oBXDialogWindow.sort,oBXDialogWindow.sort_order);oWaitWindow.Hide()},3)};this.oCheck.onclick=function(){var e=oBXDialogControls.SortSelector.SortOrderGet()=="asc"?"des":"asc";oBXDialogControls.SortSelector.SortOrderSet(e);oBXDialogWindow.sort_order=e;oWaitWindow.Show();oBXDialogControls.SortSelector.OnChange();setTimeout(function(){var e=oBXDialogControls.dirPath.Get(true);oBXDialogWindow.DisplayElementsList(arFDDirs[e],arFDFiles[e],oBXDialogWindow.view,oBXDialogWindow.filter,oBXDialogWindow.sort,oBXDialogWindow.sort_order);oWaitWindow.Hide()},3)};__SortSelector.prototype.Set=function(e,t){this.oSel.value=e;this.SortOrderSet(t);if(window.oBXDialogWindow){oBXDialogWindow.sort=e;oBXDialogWindow.sort_order=t}this.OnChange()};__SortSelector.prototype.Get=function(){return{sort:this.oSel.value,sort_order:this.SortOrderGet()}};__SortSelector.prototype.SortOrderSet=function(e){this.oCheck.setAttribute("__bx_value",e);this.oCheck.className="fd_iconkit "+(e=="asc"?"sort_up":"sort_down")};__SortSelector.prototype.SortOrderGet=function(){return this.oCheck.getAttribute("__bx_value")};__SortSelector.prototype.OnChange=function(){var e=this.Get();oBXFileDialog.UserConfig.sort=e.sort;oBXFileDialog.UserConfig.sort_order=e.sort_order}}function __FileFilter(){__FileFilter.prototype.Init=function(){var e=oBXFileDialog.oConfig.fileFilter;this.curentFilter=false;this.arFilters=[];var t=this;this.oSel=BX("__bx_file_filter");if(!oBXFileDialog.bSelectFiles){this.oSel.style.display="none";return}this.oSel.options.length=0;this.oSel.onchange=function(e){t.curentFilter=oBXDialogWindow.filter=this.value;var i=oBXDialogControls.dirPath.Get(true);oWaitWindow.Show();oBXDialogWindow.DisplayElementsList(arFDDirs[i],arFDFiles[i],oBXDialogWindow.view,oBXDialogWindow.filter,oBXDialogWindow.sort,oBXDialogWindow.sort_order);oWaitWindow.Hide()};var i=function(e,i,o){oOpt=document.createElement("OPTION");oOpt.value=t.arFilters.length;t.arFilters.push(e);oOpt.innerHTML=o+" ("+i+")";t.oSel.appendChild(oOpt);oOpt=null};if(e==""){i("*","*.*",FD_MESS.FD_ALL_FILES);return}this.oSel.style.display="block";var o,n,l,a;if(typeof e=="object"){try{for(var r=0;r<e.length;r++){a=e[r];if(typeof a.ext=="string")a.ext=a.ext.split(",");n="*."+a.ext.join(",*.");i(a.ext,n,a.title)}}catch(t){o=e;n="*."+o.join(",*.");l="";i(o,n,l)}}else if(e=="image"){o=["jpeg","jpg","gif","png","bmp"];n="*.jpeg,*.jpg,*.gif,*.png,*.bmp";l=FD_MESS.FD_ALL_IMAGES;i(o,n,l)}else{o=e.split(",");n="*."+o.join(",*.");l="";i(o,n,l)}if(oBXFileDialog.oConfig.allowAllFiles)i("*","*.*",FD_MESS.FD_ALL_FILES);this.oSel.options[0].selected="selected";this.curentFilter=0};this.Init()}function __Uploader(){this.Init()}__Uploader.prototype={Init:function(){this.oCont=BX("bxfd_upload_container");this.oIfrm=BX("bxfd_iframe_upload");this.oIfrm.src=oBXFileDialog.GetRequestUrl(getSite())+"&action=uploader&lang="+BXLang;var e=this;if(jsUtils.IsIE())this.oIfrm.onreadystatechange=function(){e.OnLoad()};else this.oIfrm.onload=function(){e.OnLoad()}},OnLoad:function(){var e=this.oIfrm.contentDocument||this.oIfrm.contentWindow.document,t=this,i=e.getElementById("__bx_fd_load_file");if(i){i.onchange=function(){var e=t.oIfrm.contentDocument||t.oIfrm.contentWindow.document;t.pFilename=e.getElementById("__bx_fd_server_file_name");t.pFilename.value=getFileName(this.value.replace(/\\/gi,"/"))}}},OnSubmit:function(){this.pFrameDoc=this.oIfrm.contentDocument||this.oIfrm.contentWindow.document;var e=this.pFrameDoc.getElementById("__bx_fd_server_file_name").value,t=oBXDialogControls.dirPath.Get(),i=oBXDialogWindow.ClientSideCheck(t,e,false,false),o,n=false;if(i!==true){alert(i);return false}try{if(!oBXFileDialog.oConfig.allowAllFiles)n=oBXDialogControls.Filter.arFilters[oBXDialogWindow.filter]}catch(e){n=false}if(n!==false){if(typeof n=="object"&&n.length>0){var l=e.lastIndexOf(".")!=-1?e.substr(e.lastIndexOf(".")+1):"";var a=false;for(var r=0;r<n.length;r++){if(n[r]==l){a=true;break}}if(!a){alert(FD_MESS.FD_INCORRECT_EXT);return false}}}for(o in arFDFiles[t]){if(arFDFiles[t][o].name==e){if(!confirm(FD_MESS.FD_LOAD_EXIST_CONFIRM))return false;this.pFrameDoc.getElementById("__bx_fd_rewrite").value="Y"}}this.pFrameDoc.getElementById("__bx_fd_upload_fname").value=e;this.pFrameDoc.getElementById("__bx_fd_upload_path").value=t;this.pFrameDoc.getElementById("__bx_fd_server_site").value=getSite();oWaitWindow.Show()},OnAfterUpload:function(e,t){oWaitWindow.Hide();oBXDialogControls.filePath.Set(e);if(t){oBXDialogControls.filePath.Set(e);oBXFileDialog.SubmitFileDialog()}else{oBXDialogWindow.LoadFolderContent(window.oBXDialogControls.dirPath.Get(),true)}}};function __History(){__History.prototype.Init=function(){this.arHistoryPath=[];this.currentPos=-1};__History.prototype.Push=function(e){var t=this.arHistoryPath.length;this.currentPos++;if(t==0||this.arHistoryPath.length>this.currentPos-1&&this.arHistoryPath[this.currentPos-1]!=e){this.arHistoryPath[this.currentPos]=e;if(t>0)this.ButBackDisable(false)}else this.currentPos--};__History.prototype.RemoveLast=function(){this.arHistoryPath.splice(2,1);this.currentPos--;if(this.currentPos==this.arHistoryPath.length-1)this.ButForwardDisable(true)};__History.prototype.Back=function(){if(this.currentPos<=0||!this.CheckButBack())return false;this.currentPos--;var e=this.arHistoryPath[this.currentPos];if(e){if(this.currentPos==0)this.ButBackDisable(true);this.ButForwardDisable(false);return e}return false};__History.prototype.Forward=function(){var e=this.arHistoryPath.length;if(!this.CheckButForward()||this.currentPos>e-2)return false;this.currentPos++;var t=this.arHistoryPath[this.currentPos];if(t){if(this.currentPos==e-1)this.ButForwardDisable(true);this.ButBackDisable(false);return t}return false};__History.prototype.CheckButBack=function(){return oBXDialogControls.dirPath.butBack.getAttribute("__bx_disable")!="Y"};__History.prototype.ButBackDisable=function(e){if(e){oBXDialogControls.dirPath.butBack.setAttribute("__bx_disable","Y");oBXDialogControls.dirPath.butBack.className="fd_iconkit path_back_dis"}else{oBXDialogControls.dirPath.butBack.setAttribute("__bx_disable","N");oBXDialogControls.dirPath.butBack.className="fd_iconkit path_back"}};__History.prototype.CheckButForward=function(){return oBXDialogControls.dirPath.butForward.getAttribute("__bx_disable")!="Y"};__History.prototype.ButForwardDisable=function(e){if(e){oBXDialogControls.dirPath.butForward.setAttribute("__bx_disable","Y");oBXDialogControls.dirPath.butForward.className="fd_iconkit path_forward_dis"}else{oBXDialogControls.dirPath.butForward.setAttribute("__bx_disable","N");oBXDialogControls.dirPath.butForward.className="fd_iconkit path_forward"}};this.Init()}function SubmitFileDialog(){var e=oBXDialogControls.filePath.Get(),t=oBXDialogControls.dirPath.Get(),i=getSite();if(e==""&&!oBXFileDialog.bSelectDirs)return alert(FD_MESS.FD_EMPTY_FILENAME);if(oBXFileDialog.oConfig.operation=="S"&&!oBXFileDialog.bSelectDirs&&e){var o=e,n="";if(e.indexOf(".")!==-1){o=e.substr(0,e.indexOf("."));n=e.substr(e.indexOf("."))}if(n==""&&oBXDialogControls.Filter){if(oBXDialogControls.Filter.arFilters&&oBXDialogControls.Filter.arFilters.length>0){var l=oBXDialogControls.Filter.arFilters[oBXDialogControls.Filter.curentFilter];if(l!="*"){if(typeof l=="object")l=l[0];e=o+"."+l.toLowerCase()}}}}if(oBXFileDialog.oConfig.operation=="O"){window[oBXFileDialog.oConfig.submitFuncName](e,t,i)}else if(oBXFileDialog.oConfig.operation=="S"){var a,r={type:false};if(oBXFileDialog.oConfig.showAddToMenuTab){a=oBXDialogControls.PageTitle.Get();var s=BX("__bx_fd_add_to_menu");if(s.checked){r={};r.type=BX("__bx_fd_menutype").value;if(BX("__bx_fd_itemtype_n").checked){r.menu_add_new=true;r.menu_add_name=BX("__bx_fd_newp").value;r.menu_add_pos=BX("__bx_fd_newppos").value;if(r.menu_add_name==""){alert(FD_MESS.FD_INPUT_NEW_PUNKT_NAME);return}}else{r.menu_add_new=false;r.menu_add_pos=BX("__bx_fd_menuitem").value}}}window[oBXFileDialog.oConfig.submitFuncName](e,t,i,a,r)}oBXFileDialog.Close()}function BXFDIsImage(e){return BXFDIsUserExt(e,["gif","jpg","jpeg","png","jpe","bmp"])}function _IsPHP(e){return BXFDIsUserExt(e,["php"])}function BXFDIsUserExt(e,t){var i=getExtension(e),o=t.length,n;for(n=0;n<o;n++)if(t[n]==i)return true;return false}function _ReplaceSpaceByNbsp(e){if(typeof e!="string")return e;e=e.replace(/\s/g,"&nbsp;");return e}function _ReplaceNbspBySpace(e){if(typeof e!="string")return e;e=e.replace(/&nbsp;/g," ");return e}function _Show_tab_OPEN(){try{BX("__bx_fd_preview_and_panel").style.display="block";BX("__bx_fd_load").style.display="none";BX("__bx_fd_container_add2menu").style.display="none"}catch(e){}}function _Show_tab_LOAD(){try{BX("__bx_fd_preview_and_panel").style.display="none";BX("__bx_fd_load").style.display="block";BX("__bx_fd_container_add2menu").style.display="none"}catch(e){}}function _Show_tab_SAVE(){try{BX("__bx_fd_top_controls_container").style.display="block";BX("__bx_fd_tree_and_window").style.display="block";BX("__bx_fd_preview_and_panel").style.display="block";BX("__bx_fd_load").style.display="none";BX("__bx_fd_container_add2menu").style.display="none"}catch(e){}}function _Show_tab_MENU(){try{if(!oBXMenuHandling.Add2MenuCheckbox.checked){oBXMenuHandling.Add2MenuCheckbox.checked=true;oBXMenuHandling.Add2MenuCheckbox.onclick()}BX("__bx_fd_top_controls_container").style.display="none";BX("__bx_fd_tree_and_window").style.display="none";BX("__bx_fd_preview_and_panel").style.display="none";BX("__bx_fd_load").style.display="none";BX("__bx_fd_container_add2menu").style.display="block";BX("__bx_fd_file_name").innerHTML=oBXDialogControls.filePath.Get()}catch(e){}}function BXMenuHandling(){var e=this;this.Add2MenuCheckbox=BX("__bx_fd_add_to_menu");this.Add2MenuCheckbox.onclick=function(e){oBXMenuHandling.Show(this.checked)};this.MenuTypeSelect=BX("__bx_fd_menutype");this.MenuTypeSelect.onchange=function(){oBXMenuHandling.ChangeMenuType()};this.NewItemOpt=BX("__bx_fd_itemtype_n");this.ExsItemOpt=BX("__bx_fd_itemtype_e");var t=function(){if(e.NewItemOpt.checked){e._displayRow("__bx_fd_e1",true);e._displayRow("__bx_fd_e2",true);e._displayRow("__bx_fd_e3",false)}else{e._displayRow("__bx_fd_e1",false);e._displayRow("__bx_fd_e2",false);e._displayRow("__bx_fd_e3",true)}};this.NewItemOpt.onclick=this.ExsItemOpt.onclick=t;BXMenuHandling.prototype.Show=function(e){if(e)BX("add2menuTable").style.display="block";else BX("add2menuTable").style.display="none"};BXMenuHandling.prototype.ChangeMenuType=function(){var e=oBXDialogControls.dirPath.Get();if(!window.arFDMenuTypes[e])return;var t=arFDMenuTypes[e].types,i=arFDMenuTypes[e].items,o=this.MenuTypeSelect.value,n;for(n=0;n<t.length;n++){if(o==t[n])break}var l=i[n];if(l.length==0){this.NewItemOpt.checked=true;this.ExsItemOpt.disabled="disabled";this._displayRow("__bx_fd_e1",true);this._displayRow("__bx_fd_e2",false);this._displayRow("__bx_fd_e3",false)}else if(this.NewItemOpt.checked){this.ExsItemOpt.disabled=false;this._displayRow("__bx_fd_e1",true);this._displayRow("__bx_fd_e2",true);this._displayRow("__bx_fd_e3",false)}var a=BX("__bx_fd_menuitem");a.options.length=0;for(n=0;n<l.length;n++)a.options.add(new Option(l[n],n+1,false,false));a=BX("__bx_fd_newppos");a.options.length=0;for(n=0;n<l.length;n++)a.options.add(new Option(l[n],n+1,false,false));a.options.add(new Option(FD_MESS.FD_LAST_POINT,0,true,true))};BXMenuHandling.prototype._displayRow=function(e,t){var i=BX(e);if(t){try{i.style.display="table-row"}catch(e){i.style.display="block"}}else{i.style.display="none"}}}function BXWaitWindow(){}BXWaitWindow.prototype={Show:function(){if(!this.oDiv){var e=BX("BX_file_dialog");if(!e)return;this.oDiv=document.createElement("DIV");this.oDiv.id="__bx_wait_window";this.oDiv.className="waitwindow";this.oDiv.style.position="absolute";this.oDiv.innerHTML=FD_MESS.FD_LOADIND;this.oDiv.width="150px";this.oDiv.style.left="320px";this.oDiv.style.top="200px";e.appendChild(this.oDiv);BX.ZIndexManager.register(this.oDiv)}this.oDiv.style.display="block";BX.ZIndexManager.bringToFront(this.oDiv)},Hide:function(){if(!this.oDiv)this.oDiv=BX("__bx_wait_window");if(this.oDiv)this.oDiv.style.display="none"}};function BXFDContextMenu(){this.Init()}BXFDContextMenu.prototype={Init:function(){this.oDiv=document.body.appendChild(jsUtils.CreateElement("DIV",{id:"__BXFDContextMenu"}));this.oDiv.innerHTML='<table cellpadding="0" cellspacing="0"><tr><td class="popupmenu"><table id="__BXFDContextMenu_items" cellpadding="0" cellspacing="0"><tr><td></td></tr></table></td></tr></table>';this.menu=new PopupMenu("__BXFDContextMenu")},Show:function(e,t,i,o){if(!o)return;this.menu.PopupHide();this.AddItems(o);if(!isNaN(e))this.oDiv.style.zIndex=e;if(!isNaN(t))this.menu.dxShadow=t;i.right=i.left+this.oDiv.offsetWidth;i.bottom=i.top;this.menu.PopupShow(i)},AddItems:function(e){var t=BX(this.menu.menu_id+"_items");while(t.rows.length>0)t.deleteRow(0);var i,o,n,l,a,r=e.length;for(n=0;n<r;n++){i=t.insertRow(-1);o=i.insertCell(-1);if(e[n]=="separator"){o.innerHTML='<table cellpadding="0" cellspacing="0" border="0" class="popupseparator"><tr><td><div class="empty"></div></td></tr></table>'}else{l=e[n];o.innerHTML='<table cellpadding="0" cellspacing="0" class="popupitem" onMouseOver="this.className=\'popupitem popupitemover\';" onMouseOut="this.className=\'popupitem\';" __bx_i="'+n+'">\n'+"\t<tr>\n"+'\t\t<td class="gutter"><div style="background-image:url('+l.src+')"></div></td>\n'+'\t\t<td class="item" title="'+(l.title?l.title:l.name)+'"'+">"+l.name+"</td>\n"+"\t</tr>\n"+"</table>";a=o.firstChild;a.onclick=function(t){e[this.getAttribute("__bx_i")].handler();oBXDialogWindow.oCM.menu.PopupHide()};a.id=null}}this.oDiv.style.width=t.parentNode.offsetWidth}};function BXFDCleanNode(e){var t;while(t=e.lastChild)e.removeChild(t)}function BXFDCompareObj(e,t){for(var i in e)if(e[i]!=t[i])return false;return true}function BXFDCopyObj(e){var t={},i;for(i in e)t[i]=e[i];return t}function getFileName(e){e=e.replace(/\\/gi,"/");return e.substr(e.lastIndexOf("/")+1)}function getExtension(e){var t=e.lastIndexOf(".");if(t>0)return t>0?e.substr(t+1).toLowerCase():""}function getFileSize(e){if(e<1024)return e+" "+FD_MESS.FD_BYTE;e=Math.round(e/1024);if(e<1024)return e+" K"+FD_MESS.FD_BYTE;e=Math.round(e/1024);if(e<1024)return e+" M"+FD_MESS.FD_BYTE}function getSite(){if(window.oBXDialogControls&&window.oBXDialogControls.currentSite)return window.oBXDialogControls.currentSite;return BXSite}
//# sourceMappingURL=file_dialog_engine.map.js